/*   1:    */ package com.atomikos.icatch.system;
/*   2:    */ 
/*   3:    */ import com.atomikos.icatch.imp.thread.InterruptedExceptionHelper;
/*   4:    */ 
/*   5:    */ public class Waiter
/*   6:    */ {
/*   7:    */   private int numActive;
/*   8:    */   private int abortCount;
/*   9:    */   private boolean noneActive;
/*  10:    */   
/*  11:    */   public Waiter()
/*  12:    */   {
/*  13: 51 */     this.numActive = 0;
/*  14: 52 */     this.abortCount = 0;
/*  15: 53 */     this.noneActive = true;
/*  16:    */   }
/*  17:    */   
/*  18:    */   synchronized int getNumActive()
/*  19:    */   {
/*  20: 59 */     return this.numActive;
/*  21:    */   }
/*  22:    */   
/*  23:    */   synchronized void getToken()
/*  24:    */     throws InterruptedException
/*  25:    */   {
/*  26: 64 */     while (!this.noneActive) {
/*  27: 65 */       wait();
/*  28:    */     }
/*  29: 66 */     this.noneActive = false;
/*  30:    */   }
/*  31:    */   
/*  32:    */   synchronized void giveToken()
/*  33:    */   {
/*  34: 71 */     this.noneActive = true;
/*  35: 72 */     notifyAll();
/*  36:    */   }
/*  37:    */   
/*  38:    */   synchronized void incActives()
/*  39:    */   {
/*  40: 77 */     this.numActive += 1;
/*  41:    */   }
/*  42:    */   
/*  43:    */   public synchronized void waitForAll()
/*  44:    */   {
/*  45:    */     try
/*  46:    */     {
/*  47: 86 */       while (this.numActive > 0) {
/*  48: 87 */         wait();
/*  49:    */       }
/*  50:    */     }
/*  51:    */     catch (InterruptedException e)
/*  52:    */     {
/*  53: 90 */       InterruptedExceptionHelper.handleInterruptedException(e);
/*  54:    */     }
/*  55:    */   }
/*  56:    */   
/*  57:    */   synchronized void incAbortCount()
/*  58:    */   {
/*  59: 96 */     this.abortCount += 1;
/*  60:    */   }
/*  61:    */   
/*  62:    */   synchronized void decActives()
/*  63:    */   {
/*  64:101 */     this.numActive -= 1;
/*  65:102 */     if (this.numActive == 0) {
/*  66:103 */       notifyAll();
/*  67:    */     }
/*  68:    */   }
/*  69:    */   
/*  70:    */   public int getAbortCount()
/*  71:    */   {
/*  72:116 */     return this.abortCount;
/*  73:    */   }
/*  74:    */ }


/* Location:           C:\myfile\mysoft\apache-maven-3.5.0-bin\apache-maven-3.5.0\myrep\com\atomikos\transactions\3.7.0\transactions-3.7.0.jar
 * Qualified Name:     com.atomikos.icatch.system.Waiter
 * JD-Core Version:    0.7.0.1
 */